<template>
    <div class="area-content-pro">
        <div id="main_e1"></div>
    </div>
</template>
<script>
import * as echarts from 'echarts';
export default {
    props: ["data"],
    data() {
        return {
        }
    },
    watch: {
        data: {
            handler(newVal, oldVal) {
                console.log(newVal, oldVal, "11111111");
                //新旧值不同
                setTimeout(() => {
                    this.iconName = this.datas
                    this.area()
                }, 1000);
            },
            deep: true,
            immediate: true
        }
    },
    mounted() {
        // this.area()
    },
    methods: {
        area() {
            var chartDom = document.getElementById('main_e1');
            console.log(chartDom);
            var myChart = echarts.init(chartDom);
            var option;
            option = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow',
                        label: {
                            backgroundColor: '#6a7985'
                        }
                    }
                },
                legend: {
                    itemHeight: '5',
                    textStyle: {
                        color: "#fff"
                    },
                    top: '3%',
                    icon: 'roundRect',
                    right: '3%',
                    data: ['人员', '生产']
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: false,
                        data: this.data.time,
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "rgba(91, 124, 144, 1)",
                            }

                        },
                        axisTick: {
                            show: false,
                        },

                        axisLabel: {
                            color: "#fff"
                        },

                        splitLine: {
                            show: false
                        },
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "rgba(91, 124, 144, 1)",
                            }

                        },
                        axisTick: {
                            show: false,
                        },

                        axisLabel: {
                            color: "#fff"
                        },

                        splitLine: {
                            show: false
                        },

                    }
                ],
                series: [
                    {
                        name: '人员',
                        type: 'line',
                        stack: 'Total',
                        smooth: true,//平滑
                        itemStyle: {
                            normal: {
                                color: 'rgba(23, 83, 255, 1)'
                            }
                        },
                        areaStyle: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {
                                    offset: 0,
                                    color: 'rgba(23, 83, 255, 1)' // 渐变起始颜色
                                },
                                {
                                    offset: 1,
                                    color: 'rgba(23, 83, 255, 0)' // 渐变结束颜色
                                }
                            ])
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        data: this.data.renyuan
                    },
                    {
                        name: '生产',
                        type: 'line',
                        stack: 'Total',
                        smooth: true,//平滑

                        itemStyle: {
                            normal: {
                                color: 'rgba(14, 236, 250, 1)'
                            }
                        },
                        areaStyle: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                {
                                    offset: 0,
                                    color: 'rgba(14, 236, 250, 1)' // 渐变起始颜色
                                },
                                {
                                    offset: 1,
                                    color: 'rgba(14, 236, 250, 0)' // 渐变结束颜色
                                }
                            ])
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        data: this.data.shengchan
                    }
                ]
            };
            option && myChart.setOption(option);
        }
    }
}
</script>
<style lang="scss">
.area-content-pro {

    #main_e1 {
        width: 363px;
        height: 214px;
    }
}
</style>